CORE_TARGET = libpix5core.so

CORE_CLS = Debug Error App Thread ThreadMan Mutex Condition Job IO FileSource linux/LinuxFS File DB Table

CORE_HDR += core/pix5core.h core/pix5main.h core/Object.h core/Buffer.h core/Str.h core/Array.h core/Dict.h
CORE_HDR += core/Platform.h core/Fifo.h core/FilePath.h core/DateTime.h core/DB_decl.h core/DB_def.h core/DB_load.h
CORE_HDR += $(patsubst %,core/%.h,$(CORE_CLS))

CORE_SRC = core/linux/Platform.cc $(patsubst %,core/%.cc,$(CORE_CLS))

CORE_OBJ = $(patsubst %.cc,%.o,$(CORE_SRC))

CORE_DEP = Makefile $(CORE_HDR)

###############################################


# COMPILER/LINKER
###############################################

CC = g++
LD = g++

# COMPILER/LINKER OPTIONS
###############################################

COPTS = -c -DPIX5DEBUG -g -Wall -Werror -pthread -o
LOPTS = -g -pthread -o

CORE_COPTS = -fPIC -DPIX5CORE $(COPTS)
CORE_LOPTS = -shared $(LOPTS)

###############################################
#all:test unittest
test: test.cc Makefile $(CORE_TARGET)
	g++ -DPIX5DEBUG -g -Wall -Werror -pthread -L. -Icore -lpix5core -o test test.cc

unittest: unittest.cc Makefile $(CORE_TARGET)
	g++ -DPIX5DEBUG -g -Wall -Werror -pthread -L. -Icore -lpix5core -o unittest unittest.cc

# CORE RULES
###############################################
$(CORE_TARGET): $(CORE_OBJ) $(CORE_DEP)
	$(LD) $(CORE_LOPTS) $(CORE_TARGET) $(CORE_OBJ)

$(CORE_OBJ): %.o: %.cc $(CORE_DEP)
	$(CC) $(CORE_COPTS) $@ $<

###############################################

clean:
	@rm -f $(CORE_TARGET) $(CORE_OBJ) test unittest

###############################################


###############################################
